package com.wzcl.app.dao.repository;

import com.wzcl.app.dao.model.FileGroup;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface FileGroupRepository extends JpaRepository<FileGroup,Integer>, JpaSpecificationExecutor<FileGroup> {

    @Query("SELECT m FROM FileGroup m WHERE m.name = ?1 AND m.parentId IS NULL")
    FileGroup findByNameWithNoParentId(String Name);

    FileGroup findByNameAndParentId(String Name, Integer parentId);

    List<FileGroup> findAllByParentId(Integer parentId);
}
